﻿using B.S.GridManage.Api.Write.Application.Command.LogicalGrid;
using B.S.GridManage.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.GridManage.Api.Write.Controllers
{
    /// <summary>
    /// 逻辑网格控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LogicalGridController : ControllerBase
    {
        private readonly IMediator mediator;

        public LogicalGridController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 创建逻辑网格接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public  Task<ApiResult<int>> CreateLogicalGrid(CreateLogicalGridCommand request) { 
            return mediator.Send(request);
        }
        /// <summary>
        /// 更新逻辑网格接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public   Task<ApiResult<int>> UpdateLogicalGrid(UpdateLogicalGridCommand request) {
            return mediator.Send(request);
        }
        
        /// <summary>
        /// 删除逻辑网格接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public   Task<ApiResult<int>> DelLogicalGrid(DelLogicalGridCommand request) {
            return mediator.Send(request);
        }

    }
}
